home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / security / UNIX-password-security.txt.Z / UNIX-password-security.txt
Encoding:
Text File  |  1994-02-07  |  18.1 KB  |  421 lines

  1.  
  2.                          UNIX Password Security
  3.  
  4.                              Walter Belgers
  5.                          walter@giga.win.tue.nl
  6.  
  7.                             December 6, 1993
  8.  
  9.  
  10. 1. Introduction
  11.  
  12. This document was written to make system administrators aware of the
  13. importance of well-chosen passwords. Easy-to-guess passwords offer
  14. hackers the possibility to enter a system. (`Crackers' is a better
  15. term, because `hackers' is historically reserved for people who take
  16. the most out of their computer because of their great knowledge of
  17. soft- or hardware. I will continue to use the term `hacker' because
  18. this is common in literature.) More and more computers are being
  19. connected to the world-wide Internet (the latest estimations speak of
  20. about 1.5 billion systems). This means there will be more and more
  21. users, and therefore more and more hackers. By means of good
  22. password-security, one can protect a system from newbie hackers.
  23.  
  24. There are many types of systems, and every one has a lot of security
  25. aspects to it. I will restrict myself to the password-security of UNIX
  26. systems. The reason being that UNIX systems are very popular,
  27. especially in an educational environment, where one can expect an
  28. increased concentration of hackers due to the openness that is
  29. appreciated in such environments. This is in contrast to a commercial
  30. environment, where data has to be protected. E.g. against competitors.
  31. There are many ways to hack a UNIX system, and there are many programs
  32. for finding a user's password. These programs can be used by people who
  33. have little knowledge of UNIX.  Choosing good passwords can therefore
  34. help in keeping newbie hackers out. (`Advanced hackers' are often
  35. capable of entering a system without using passwords.  This implies
  36. that the security of a system depends not solely on well-chosen
  37. passwords.)
  38.  
  39. Besides the importance of good passwords (i.e. not easily guessable) we
  40. will take a look at how they work. Next we will see an actual example
  41. which shows how bad passwords are usually chosen. To conclude I will
  42. give several methods for chosing good passwords.
  43.  
  44. 2. The importance of good passwords
  45.  
  46. The goal of a hacker is usually obtaining the superuser-status (`root').
  47. The normal strategy to do this is using badly installed software, bugs
  48. in (system)software and human errors. There are several ways to hack a
  49. computer, but most ways require extensive knowledge. A (relatively) easy
  50. way is logging in as a normal user and searching the system for bugs to
  51. become superuser. To do this, the hacker will have to have a valid
  52. usercode/password combination to start with.
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.                    - Page 1 -
  61.  
  62. It is of utmost importance that all (!) users on a system choose a
  63. password that is not easy to guess. The security of each individual
  64. user is closely related to the security of the whole system. Users
  65. often have no idea how a multi-user system works and don't realise that
  66. they, by chosing an easy to remember password, indirectly make it
  67. possible for an outsider to manipulate the entire system. It is
  68. essential to educate the users well to avoid attitudes like the one
  69. described in [Muf]: "It doesn't matter what password I use on _MY_
  70. account, after all, I only use it for laserprinting...". The users have
  71. to get involved with the security of the system they are working on. In
  72. [Pet] we read "Users have a responsibility to employ available security
  73. mechanisms and procedures for protecting their own data. They also have
  74. a responsibility for assisting in the protection of the systems they
  75. use".  It also says that it is important to notify the users of the
  76. security guidelines. A solution might be giving new users a limited
  77. course. Or at least make them understand why good passwords are
  78. essential.  This can be done e.g. when a user gets his or her initial
  79. password from the system administrator.
  80.  
  81. 3. How a hacker finds a password
  82.  
  83. Most UNIX systems don't use the so-called shadow passwordfiles which we
  84. will look at in a moment. In most cases, the passwords are stored
  85. encrypted in the file /etc/passwd, or, if the system is a client, on
  86. the server. In the latter case, one can get the passwordfile by giving
  87. the command `ypcat passwd'.
  88.  
  89. A line from the passwordfile looks like this:
  90.  
  91.    account:coded password data:uid:gid:GCOS-field:homedir:shell
  92.  
  93. A user with account gigawalt, crypted password fURfuu4.4hY0U, userid
  94. 129 (a user with userid 0 (of which there can be more than one) is
  95. superuser), groupid 129, information (GCOS) Walter Belgers,
  96. homedirectory /home/gigawalt and shell /bin/csh will have an entry in
  97. /etc/passwd like this:
  98.  
  99.    gigawalt:fURfuu4.4hY0U:129:129:Walter Belgers:/home/gigawalt:/bin/csh
  100.  
  101. Things are a bit different when a shadow passwordfile is being used.
  102. All coded password data is replaced with a `*' in /etc/passwd, and a
  103. second file (the shadowfile) is used to store the original data. This
  104. file can only be read with sufficient privileges so that normal users
  105. cannot get the crypted passwords.
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.                                - Page 2 -
  121.  
  122. Passwords are being crypted using the DES algorithm. DES (`Data
  123. Encryption Standard') is an American encryption standard since 1979.
  124. With DES it is possible to encrypt and decrypt data using a key. UNIX
  125. password encryption uses the DES algorithm 25 times in a row. The first
  126. DES round uses 64 0-bits as input and encrypts them with the password
  127. the user inputs, with a permutation taking place during the encryption
  128. process. There are 4096 possible permutations. The permutation used is
  129. randomly chosen for each user. The chosen permutation is coded into two
  130. bytes called `salt'. The salt is stored in the passwordfile. The output
  131. is used as input for the next DES round, which uses the same key and
  132. permutation. This process repeats until there is a final output from
  133. the 25th DES round. This output is coded into eleven bytes which are
  134. put in the passwordfile. So the coded password data in the passwordfile
  135. consists of thirteen bytes, first the salt and then the encrypted
  136. password.
  137.  
  138. This method of encryption is almost irreversible, which means that it
  139. is easy to encrypt a string, but it is impossible to find the original
  140. of a string encrypted in the way described above, except by
  141. systematically trying out all possible keys and salts. (By impossible
  142. we mean here that there is no known method that does this quicker.) It
  143. is however possible to find the original of a string encrypted using
  144. _single_ DES. For more information concerning single DES encryption see
  145. [Til]. If it's impossible to decrypt the encrypted password, how can a
  146. user log in? This works as follows: the user inputs his or her password
  147. which is used as key to crypt 64 0-bits using the aforementioned
  148. method, using the salt as it can be found in the passwordfile for that
  149. particular user. If the output corresponds to the eleven bytes that
  150. represent the crypted password in the passwordfile the password is
  151. considered valid and the user will be permitted to access the system.
  152. For more information on the precise working of DES on UNIX see [Fel2].
  153.  
  154. Schematically it looks like this:
  155.  
  156.  
  157.                     ----------------      (salt)
  158.                     | 25x DES      | <---------------vv
  159.    64 0-bits ---->  |  encryption  | ----            fURfuu4.4hY0U ------
  160.                     ----------------    |            (from /etc/passwd) |
  161.                           ^             |                               |
  162.                           | (key)       -------------> Rfuu4.4hY0U -----|
  163.                           |                           (result)          |
  164.                           |                                             |
  165.                   inputted password                                     |
  166.                                         ---------------------------------
  167.                                         |
  168.                                         --> correspondance: password
  169.                                                             accepted 
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.                                - Page 3 -
  181.  
  182. As I just pointed out it is not possible (in real life) to decrypt
  183. passwords.  However, it is possible to encrypt 64 0-bits with some
  184. words and see if the result `incidentally' is the password. Then the
  185. account is hacked.  One could remark that it must be possible to check
  186. all possible passwords this way. However, this would take the fastest
  187. computer longer than the time the universe exists. By trying out only
  188. passwords consisting of six lowercase characters, it becomes possible
  189. to try out all combinations in reasonable time, provided one has an
  190. extremely powerful computer. The latest record for passwords consisting
  191. of six lowercase characters stands at one hour per user. Passwords of
  192. accounts that are attractive to hackers (the ones with a lot of
  193. privileges) should therefore never consist solely of lowercase
  194. characters!
  195.  
  196. We see that the usual way to find passwords is by guessing them. So you
  197. have to make sure users do not use easy-to-guess passwords, i.e.
  198. passwords that can be found in lists (a dictionary, an encyclopedia,
  199. files with astronomical terms, flora and fauna, etc.). It is very easy
  200. to obtain such lists via the Internet.
  201.  
  202. Suppose a line from the passwordfile looks like this:
  203.  
  204.    gigawalt:fURfuu4.4hY0U:129:129:Walter Belgers:/home/gigawalt:/bin/csh
  205.  
  206. Then passwords that should NOT be used are e.g.:
  207.  
  208.  . all English words and derivatives (so `laugh', `laughs', `laughing',
  209.    etc.)
  210.  . all words from a foreign language (it is easy to get foreign
  211.    dictionaries)
  212.  . words that can be found in the passwordfile itself like Walter,
  213.    Belgers, gigawalt, etc.
  214.  . patterns like 123456, qwerty, etc.
  215.  . geographical names
  216.  . words from an encyclopedia (`Socrates')
  217.  . the license plate of a car, the roomnumber, the phonenumber or other
  218.    things that have something to do with the owner of the account
  219.  . given names
  220.  . variations of these (walter, WALTER, retlaw, Walter, wAlter, walter0,
  221.    walt3r, Retlaw4,...) Also take into account doubling words or adding a
  222.    random character.
  223.  
  224. 4. An actual example
  225.  
  226. To show how users choose their passwords badly, I used a password
  227. guessing program on a passwordfile of a system in operation.
  228.  
  229. The program I used was Crack v4.1 with ufcrypt (ultra-fast crypt, a fast
  230. implementation of the DES algorithm) on a network of SUN ELC computers.
  231. The performance of these computers (20 MIPS) is comparable to that of a
  232. modern PC. The program was stopped before it was finished after almost
  233. 60 hours. The passwords that were found were found within the first 25
  234. hours.
  235.  
  236.  
  237.  
  238.  
  239.  
  240.                                - Page 4 -
  241.  
  242. Results:
  243.  
  244. Type of machines:           11x SUN ELC
  245. Total number of accounts:   521
  246. Number of hacked accounts:  58 (11.1%) (with interactive shell 56 (10.7%))
  247. Total time                  59:13 (real time, not CPU time)
  248.  
  249.                  1 lists                  42 (7.2%)
  250.                  2 common names           1  (0.2%)
  251.                  3 user/account name      5  (0.9%)
  252.                  4 phrases and patterns   3  (0.5%)
  253.                  5 women's names          2  (0.3%)
  254.                  6 men's names            4  (0.7%)
  255.                  7 cities                 1  (0.2%)
  256.  
  257. Passwords found:
  258.  
  259.  . cyclades, paardens, fiesta, regen, gnosis, police, fuselier, ballon,
  260.    smaragd, marques, farao, kasteel, valent, adagio, clematis,
  261.    gehannes, koeien, gnomen, onderkin, zeilboot, druppel, fietsen,
  262.    testen, marathon, tamtam, global, vrijheid, wolf, kwiek, basket,
  263.    stones, klomp9, fiets9, Zoutje, Biefstuk, neenee, tnbrg (this is
  264.    `tonbrug' without vowels).
  265.  . fischer.
  266.  . guest had password guest. This is not a user's fault of course, but
  267.    the fault of the system administrator. It has to be seen whether or
  268.    not logging in as `guest' with password `guest' is criminal in the
  269.    Netherlands.
  270.  . qwerty, unesco.
  271.  . heather, joanne.
  272.  . piet, atilla, Frans2, vatsug (this is `gustav' spelled backwards).
  273.  . adelaide.
  274.  
  275. Some people have studied the amount of passwords that is easily
  276. guessable in the past. In [Kle] Daniel Klein finds 21% of 15,000
  277. passwords using one week CPU time. The first 2.7% was found within 15
  278. minutes (people who used their account as password, e.g. account
  279. gigawalt, with password gigawalt). The categories in which over 1% of
  280. the 15,000 passwords were found are:
  281.  
  282.                      lists                  7,4%
  283.                      common names           4,0%
  284.                      user/account name      2,7%
  285.                      phrases and patterns   1,8%
  286.                      women's names          1,2%
  287.                      men's names            1,0%
  288.                      machinenames           1,0%
  289.  
  290. Comparing these results to the ones above is of little use because of
  291. the limited extent of this investigation.
  292.  
  293. A somewhat more extensive research (see [Far]) was concerned with
  294. passwordfiles of several .COM systems (computers owned by US
  295. companies). One would expect companies to have good security
  296. measurements, but the passwords kept coming in, with the first
  297. root-password (!) after little more than an hour. (There was a total of
  298. 1594 passwords of which 50 had been guessed within 15 minutes, and 90
  299. after 35 minutes.)
  300.                                - Page 5 -
  301.  
  302. 5. Picking good passwords
  303.  
  304. The above illustrates the importance of a good password for every
  305. user.  We will look at some methods for choosing good passwords. A good
  306. password consists of 8 characters (a UNIX password can be up to eight
  307. characters, any extra characters will be discarded, making the
  308. passwords `Still won't talk, eh, Spiff?' and `Still wo' mutually
  309. interchangable). It has to be hard to guess but easy to remember,
  310. because otherwise, users will be tempted to write down their password
  311. which totally takes away the function of a it.
  312.  
  313. Pick a password that not only consists of just upper- or lowercase
  314. characters, or only one capital (`seCret' is thus a bad password). It
  315. is preferable to use a non-alfanumeric character in the password
  316. (%,=,*, etc.). The use of control characters is possible, but not all
  317. control characters can be used, and it can give rise to problems with
  318. some networking protocols.
  319.  
  320. A few methods:
  321.  . Concatenate two words that together consist of seven characters and
  322.    that have no connection to eachother. Concatenate them with a
  323.    punctuation mark in the middle and convert some characters to
  324.    uppercase. Examples: `Pit+idEa', `plOVer#me'.
  325.  . Use the first characters of the words of a certain (not too common)
  326.    sentence. When we use the sentence `My goldfish are called
  327.    Justerini and Brooks!' as example, we would get the password
  328.    `MgacJaB!'. (Also in this case make sure you use an eight-character
  329.    password with uppercase characters and/or punctuation marks.)
  330.  . Alternately pick a consonant and one or two vowels resulting in a
  331.    pronouncable (and therefore easy to remember) word. Examples:
  332.    `koDupaNy', `eityPOop'.
  333.  
  334. 6. Reducing break-in possibilities
  335.  
  336. It is important for users to have hard to guess but in the meantime easy
  337. to remember passwords. There are methods for generating such passwords.
  338. System operators should inform the users about the importance of good
  339. passwords.
  340.  
  341. To reduce the risk of a break-in there are several possibilities:
  342.  
  343.  . Make sure the users know why a good password is important and how
  344.    they can choose one.
  345.  . Install a new /bin/passwd (or yppasswd) that checks whether the
  346.    password is not too obvious (by checking if it contains punctuation
  347.    marks, or by investigating if the password can be found in standard
  348.    wordlists).
  349.  . Install a shadow passwordfile (this involves changing some software).
  350.  . Let passwords expire, for example after three months for regular
  351.    users, after a month for users with extra privileges. The timespan a
  352.    password lives should not be chosen too small. What will still exist
  353.    is the danger of users using series of passwords, like `Secret1',
  354.    `Secret2',... making it easy for a hacker to, once he has obtained
  355.    a password, guess the successor.
  356.  
  357.  
  358.  
  359.  
  360.                                - Page 6 -
  361.  
  362.  . Use a program that hacks passwords to check if some users have
  363.    guessable passwords. Let those users visit you personally to inform
  364.    them about the fact that a good password is everyone's concern.
  365.  . Switch to single-use passwords (this is radical and requires some
  366.    investments, see [Ven]).
  367.  . Use passwords of accounts with privileges like that of root on the
  368.    console only to avoid eavesdropping the network. When impossible,
  369.    try to avoid logging in on such accounts from computers or terminals
  370.    that are connected to a LAN segment on which people can easily
  371.    and/or anonymously wiretap the network, like classrooms.
  372.  . Keep in mind that total system security is as weak as the weakest
  373.    chain. Also keep in mind that a system with good passwords alone is
  374.    not yet a secure system.
  375.  
  376. 7. Bibligraphy
  377.  
  378. [Bel]  Walter Belgers, Password Security - A Case Study (in Dutch),
  379.        TimeWasters Online Magazine #5, march 9, 1993, can be obtained by
  380.        sending email with Subject `TOM5' to
  381.        timewasters-request@win.tue.nl.
  382.  
  383. [Cur]  David A. Curry, UNIX System Security, Addison-Wesley, 1992.
  384.  
  385. [Far]  Dan Farmer, Wietse Venema, Improving the Security of Your Site by
  386.        Breaking Into it, USENET newsgroup comp.security.unix, can be
  387.        obtained via ftp from ftp.win.tue.nl as
  388.        /pub/security/admin-guide-to-cracking.Z, 1993.
  389.  
  390. [Fel1] David C. Feldmeier, A High-Speed Software DES Implementation, can
  391.        be obtained by anonymous ftp from thumper.bellcore.com as
  392.        /pub/crypt/des.ps.Z, 1989.
  393.  
  394. [Fel2] David C. Feldmeier, Philip R. Karn, UNIX Password Security - Ten
  395.        Years Later, Proceedings of Advances in Cryptology - CRYPTO '89,
  396.        1989.
  397.  
  398. [Kle]  Daniel V. Klein, ``Foiling the Cracker'': A Survey of, and
  399.        Improvements to, Password Security (revised paper), Proceedings
  400.        of the USENIX Security Workshop, summer 1990.
  401.  
  402. [Muf]  Alec E. Muffet, Almost Everything You Wanted To Know About
  403.        Security (but were afraid to ask!), USENET newsgroup
  404.        alt.security.
  405.  
  406. [Pet]  R. Pethia, S. Crocker, B. Fraser, RFC1281: Guidelines for the
  407.        Secure Operation of the Internet, november 1991.
  408.  
  409. [Til]  Henk C.A. van Tilborg, An Introduction to Cryptology, Kluwer
  410.        Academic Publishers, 1988.
  411.  
  412. [Ven]  Wietse Venema, Using SecurID tokens in an open multi-host UNIX
  413.        environment, can be obtained by anonymous ftp from
  414.        ftp.nic.surfnet.nl as /surfnet/net-security/docs/securid.ps,
  415.        1993.
  416.  
  417.  
  418.  
  419.  
  420.                                - Page 7 -
  421.